package com.cheifsteam.springframework.support;

import com.cheifsteam.springframework.config.BeanDefinition;
import com.cheifsteam.springframework.beans.exception.BeansException;

/**
 * @author 屈燃希
 * @date 2025/1/18 23:04
 * @content
 */
public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFactory {

    @Override
    protected Object createBean(String name, BeanDefinition beanDefinition) {
        Object bean = null;
        try {
            bean = beanDefinition.getBeanClass().newInstance();
        }  catch (IllegalAccessException | InstantiationException e) {
            throw new BeansException("Instantiation of bean failed", e);
        }
        addSingleton(name, bean);
        return bean;
    }
}
